package com.tao.base.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    T data;
    Integer code;
    String message;

    public static <T> Result<T> success(String msg) {
        return new Result<T>(null, 1, msg);
    }

    public static <T> Result<T> success(T data) {
        return new Result<T>(data, 1, "success");
    }

    public static <T> Result<T> error(String message) {
        return new Result<T>(null, 0, message);
    }

    public static <T> Result<T> error() {
        return new Result<T>(null, 0, "error");
    }

    public static <T> Result<T> success() {
        return new Result<T>(null, 1, "操作成功");
    }
}
